package com.meida.module.bus.provider.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.google.common.collect.Lists;
import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.mybatis.query.CriteriaSave;
import com.meida.module.bus.client.entity.BbpUnit;
import com.meida.module.bus.provider.mapper.BbpUnitMapper;
import com.meida.module.bus.provider.service.BbpUnitService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 接口实现类
 *
 * @author flyme
 * @date 2020-09-26
 */
@Service
@Transactional(rollbackFor = Exception.class)
@DS("dbr")
public class BbpUnitServiceImpl extends BaseServiceImpl<BbpUnitMapper, BbpUnit> implements BbpUnitService {

//    @Override
//    public ResultBody beforeAdd(CriteriaSave cs, BbpUnit bbw, EntityMap extra) {
//        return ResultBody.ok();
//    }
//
//    @Override
//    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
//    public ResultBody beforePageList(CriteriaQuery<BbpUnit> cq, BbpUnit bbw, EntityMap requestMap) {
//        String valueKey = requestMap.get("valueKey");
//        String value = requestMap.get("value");
//        cq.like(valueKey, value);
//        cq.or();
//        cq.like("MATERIALNAME", value);
//        return ResultBody.ok();
//    }
//
//    @Override
//    public void afterPageList(CriteriaQuery<BbpUnit> cq, List<EntityMap> data, ResultBody resultBody) {
//        List<EntityMap> outData = Lists.newArrayList();
//        data.stream().forEach(obj -> {
////            EntityMap entityMap = new EntityMap();
//            obj.put("materialCode", obj.get("MATERIALCODE") + " " + obj.get("MATERIALNAME"));
////            outData.add(entityMap);
//        });
////        resultBody.data(outData);
//    }
}
